#define  _CRT_SECURE_NO_WARNINGS  1
#include <stdio.h>
int main()
{
	double x = 0;
	scanf("%lf", &x);
	double y = 0;
	if (x < 0 && x != -3)
	{
		y = x * x + x - 6;
	}
	else if (x >= 0 && x < 10 && x != 2 && x != 3)
	{
		y = x * x - 5 * x + 6;
	}
	else
	{
		y = x * x - x - 1;
	}

	printf("%.3lf", y);

	return 0;
}